<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <form action="<?php echo $this->createUrl('/score_section/default/index'); ?>" method="get" name="search">
            <table>
                <tbody>
                    <tr>
                        <td width="100" align="right" class="pt10 pr2 pl19">考试项目：</td>
                        <td width="600" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"><!--边框-->
                                <span class="fl select_shelter"><!--遮挡默认边框-->
                                    <select name="exam_id" class="fl fontc_666" id="search_exam_id">
                                        <option value="0">请选择</option>
                                        <?php if (!empty($examArray)): ?>
                                            <?php foreach ($examArray as $eVal): ?>
                                                <option value="<?php echo $eVal['exam_id']; ?>" <?php if ($search['exam_id'] == $eVal['exam_id'])echo 'selected';?>><?php echo $eVal['exam_term_name']; ?></option>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td width="277" align="right" class="pt10"><input type="submit" value="查询" class="cursor b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12" /></td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt10 pr2 pl19"></td>
                        <td colspan="2" class="">
                            <ul class="clearfix">
                                <li class="clearfix"><a href="javascript:copyData()"><font class="fontc_blue1">复制考试项目配置数据</font></a></li>
                            </ul>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" style="margin-right:30px;" class="cursor fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 add" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 ml20 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40 myTable">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="63" align="center" class="m_hr_t m_hr_b pl10"><input type="checkbox" class="checkboxs"></th>
                        <th width="230" align="left" class="m_hr_t m_hr_b pl10"><span>考试项目</span></th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">序号</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">下限</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">上限</th>
                        <th width="120" align="center" class="m_hr_t m_hr_b">级差</th>
                        <th width="115" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="center" class="m_hr_b pl10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['es_id'];?>" class="checkbox"></td>
                                <td align="left" class="m_hr_b pl10">
                                    <span style="line-height:1.5;padding:10px 0;display: block;">
                                        <?php echo isset($examArray[$value['exam_id']]['exam_term_name']) ? $examArray[$value['exam_id']]['exam_term_name'] : ''; ?>
                                    </span>
                                </td>
                                <td align="center" class="m_hr_b"><?php echo $value['es_id']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['score_type1']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['score_type2']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['score_type3']; ?></td>
                                <td align="center" class="m_hr_b">
                                    <a href="javascript:;" class="edit" sid="<?php echo $value['es_id']; ?>" title="编辑" ><img src="/themes/default/images/Sipei/edit.png" class="pr15" /></a>
                                    <a href="javascript:;" class="del" sid="<?php echo $value['es_id']; ?>" title="删除" ><img src="/themes/default/images/Sipei/delate.png" /></a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr><td align="center" colspan="7" class="m_hr_b"><h2>暂时没有设置信息</h2></td> </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>
<script>
    $(function() {
        $(".edit").click(function() {
            var sid = $(this).attr('sid');
            api = $.dialog({
                id: 'testID2',
                lock: true,
                padding: 0,
                fixed: true,
                title: "编辑",
                width: 480,
                height: 330,
                max: false,
                min: false
            });

            $.get('/score_section/default/update', {sid: sid,time:new Date()}, function(html) {
                api.content(html);
            });
        });

        $(".add").click(function() {
            api = $.dialog({
                id: 'testID2',
                lock: true,
                padding: 0,
                fixed: true,
                title: "新增",
                width: 480,
                height: 330,
                max: false,
                min: false
            });

            $.get('/score_section/default/add', {}, function(html) {
                api.content(html);
            });
        });

        $(".del").click(function() {
	       	 var sid = $(this).attr('sid');
	         var that = $(this);
            $.dialog.confirm('确定删除吗', function() {
                $.get('/score_section/default/delete', {sid: sid}, function(html) {
                    if (html == 1) {
                        that.parents('tr').remove();
                    } else {
                        alert("删除失败");
                    }
                });
            });

        });

    });
    function delete_all(){
    	var aa='';
    		$("input[name='deleteAll[]']:checkbox:checked").each(function(){
						aa+=$(this).val()+',';
					});
					if(aa == ''){
						$.dialog.alert("请选择要删除条目");
						return false;
					}
					$.dialog.confirm('确定删除所选数据吗', function() {
    		aa+=0;
    	
    		$.get('/score_section/default/delete_all', {id: aa}, function(data) {
    			location.reload();
    		   
    		});
    	});
    }
	$(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");
                        if (checkedS) {
                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })
                
function copyData(){
	var exam_id = $("#search_exam_id").val();
	if(exam_id == 0){
		$.dialog.alert("请选择考试项目");
	}else{
		api = $.dialog({
			id: 'testID2',
			lock: true,
			padding: 0,
			fixed: true,
			title: "复制",
			width: 480,
			height: 180,
			max: false,
			min: false
		});
		
		$.get('/score_section/default/exam_select', {exam_id: exam_id,time:new Date()}, function(html) {
			api.content(html);
		});
	}
	
}
</script>